﻿using System;
using System.Data.Entity;
using System.Data.EntityModel;
using System.Linq;
using AceSoft.RetailPlus.HRM.MembersModel;


namespace AceSoft.RetailPlus
{
    public class HRMRewardCardsMock
    {
        public HRMRewardCardsMock()
        {
            Members _Members = new Members();

            DbSet<VIPRewardCard> _VIPRewardCards = _Members.HRMRewardCards;

            Console.WriteLine("Available VIPRewardCard");
            foreach (VIPRewardCard _VIPRewardCard in _VIPRewardCards)
            {
                Console.WriteLine(" {0} : {1}", _VIPRewardCard.CardNo, _VIPRewardCard.EmbossedCardName);
            }

            Console.WriteLine("Deleting VIPRewardCard");
            foreach (VIPRewardCard _VIPRewardCard in _VIPRewardCards)
            {
                _VIPRewardCards.Remove(_VIPRewardCard);
                Console.WriteLine(" ContactDetail: {0} deleted.", _VIPRewardCard.CardNo);
            }
            _Members.SaveChanges();

            Console.WriteLine("Adding VIPRewardCard");
            ContactModel.Contact _Contact = new ContactModel.Contact();
            DbSet<ContactModel.ContactDetail> _ContactDetails = _Contact.ContactDetails;

            foreach (ContactModel.ContactDetail _ContactDetail in _ContactDetails)
            {
                _VIPRewardCards.Add(new VIPRewardCard { ID = _ContactDetail.ID, CardNo = _ContactDetail.FirstName,
                                                        ExpiryDate  = DateTime.Now.AddYears(1),
                                                        CardStatus = 0,
                                                        CurrentPoints = 0,
                                                        EmbossedCardName = "ECN" + _ContactDetail.OtherName });
                Console.WriteLine(" CardNo {0} added.", _ContactDetail.FirstName);
            }
            _Members.SaveChanges();

            Console.WriteLine("Relisting VIPRewardCard");
            foreach (VIPRewardCard _VIPRewardCard in _VIPRewardCards)
            {
                Console.WriteLine(" {0} : {1}", _VIPRewardCard.CardNo, _VIPRewardCard.EmbossedCardName);
            }
        }
    }
}
